2.10 布尔值和对象
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<script type="text/javascript">
<!--1、boolean:布尔值,只有false和true,在运算中false表示0,true表示1-->
<!--2、object:对象类型-->
var t1=4<7;
var b1=typeof t1;
document.write("类型:",b1,",","4<7返回值为:",t1,"<br>")
var t2=false;
var b2=typeof t2;
document.write("类型:",b2,",","false返回值为:",t2,"<br>")
var t3=false+true;
var b3=typeof t3;
document.write("类型:",b3,",","false+true返回值为:",t3,"<br>")
var t4=10+true;
var b4=typeof t4;
document.write("类型:",b4,",","10+true返回值为:",t4,"<br>")
var t5=[1,2,3,4];
var b5=typeof t5;
document.write("类型:",b5,",","[1,2,3,4]返回值为:",t5,"<br>")
var t6={"name":"张三","age":"40"};
var b6=typeof t6;
document.write("类型:",b6,",",'{"name":"张三","age":"40"}返回值为:',t6,"<br>")
</script>
</head>
<body>
</body>
</html>
返回值:
类型:boolean,4<7返回值为:true
类型:boolean,false返回值为:false
类型:number,false+true返回值为:1
类型:number,10+true返回值为:11
类型:object,[1,2,3,4]返回值为:1,2,3,4
类型:object,{"name":"张三","age":"40"}返回值为:[object Object]